package com.example.shaidemo;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import java.util.Objects;

public class MyPageAdapter extends FragmentStateAdapter {

    String[] titles=new String[]{"打车","酒店","我的","防杀熟"};

    public MyPageAdapter(@NonNull FragmentActivity fa) {
        super(fa);
    }
    @NonNull
    @Override
    public Fragment createFragment(int position) {

        if(position == 0){
            return new CarListFragment();
        }else if(position ==1){
            return new HotelListFragment();
        }else if(position==2){
            return new MineFragment();
        }else if(position==3){
            return new TipsFragment();
        }else{
            return new ShowTipFragment();
        }
    }

    @Override
    public int getItemCount() {
        return 5;
    }
}
